#ifndef LINE_EDIT_DELEGATE_H
#define LINE_EDIT_DELEGATE_H

#include <QtGui/QStyledItemDelegate>

namespace gui
{

class LineEditDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    LineEditDelegate(QWidget* parent = 0);
    ~LineEditDelegate();

    void setRole(Qt::ItemDataRole role);
    void setInputMask(const QString& inputMask);
    void setValidator(const QSharedPointer<QValidator>& validator);

    // QStyledItemDelegate
    QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
        const QModelIndex& index) const;

    void setEditorData(QWidget* editor, const QModelIndex& index) const;
    void setModelData(QWidget* editor, QAbstractItemModel* model,
        const QModelIndex& index) const;

    void updateEditorGeometry(QWidget* editor,
        const QStyleOptionViewItem& option,
        const QModelIndex& index) const;

private:
    Qt::ItemDataRole m_role;
    QString m_inputMask;
    QSharedPointer<QValidator> m_validator;
};

} // namespace gui

#endif
